package com.ruoyi.ipms_patent.controller;

import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.ipms_patent.service.InventorService;
import com.ruoyi.system.api.dto.InventorDto;
import com.ruoyi.system.api.entity.Inventor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/patent/inventor")
public class InventorController extends BaseController {

    @Resource
    private InventorService inventorService;

    /*新增发明人*/
    @PostMapping("/add")
    public AjaxResult addOne(@RequestBody Inventor inventor) {
        Inventor result = inventorService.addInventor(inventor);
        return result != null ? AjaxResult.success("新增成功", result) : error("新增失败");
    }

    /*全部发明人列表（专利id）*/
    @GetMapping("/find/{patentId}")
    public TableDataInfo findListByCaseId(@PathVariable("patentId") Integer patentId) {
        List<Inventor> caseList = inventorService.findInventorList(patentId);
        return getDataTable(caseList);
    }


    /*全部发明人列表（all）*/
    @PostMapping("/allInventorList")
    public TableDataInfo findAllInventor(@RequestBody InventorDto inventorDto){
        startPage();
        List<InventorDto> inventorList = inventorService.findAllInventor(inventorDto);
        return getDataTable(inventorList);
    }

}
